package com.persia.persistence

import com.jolbox.bonecp._

object DbPool {
  
  val ds = initDataSource
  
   def initDataSource() ={
    //load the db driver
    Class.forName("com.mysql.jdbc.Driver")
    // create a new datasource object
    val ds = new BoneCPDataSource() 
    // set the JDBC url
 	ds.setJdbcUrl("jdbc:mysql://localhost:3306/demo?characterEncoding=utf-8")
 	// set the username
	ds.setUsername("root")			
	ds.setPassword("root")
	ds.setMinConnectionsPerPartition(2)
	ds.setMaxConnectionsPerPartition(30)
	ds.setPartitionCount(3)
	ds
  }
  
  def shutdown(){
    ds.close()
  }
}